package math.matrix;

/**
 *
 * Fully Tested: No
 * Fully Documented: No
 * Created: 20-May-2012
 * Last Updated: 20-May-2012
 *
 * @author Shimu Wu
 */
public class FloatMatrix {

    /**
     * The number of rows in the matrix.
     */
    private int maxY;

    /**
     * The number of columns in the matrix.
     */
    private int maxX;

    /**
     * The data in the matrix
     */
    private int[] data;

    public FloatMatrix(int row, int column, int[] data) {
        this.maxY = row;
        this.maxX = column;
        this.data = data;
    }

    public FloatMatrix(int row, int column) {
        this(row, column, new int[row * column]);
    }

    public final int get(int x, int y) {
        return this.data[x + this.maxY * y];
    }

    public final void set(int x, int y, int value) {
        this.data[x + this.maxY * y] = value;
    }

    public boolean equals(FloatMatrix other) {
        if ((this.maxY == other.maxY) && (this.maxX == other.maxX)) {
            for (int x = 0; x < maxX; x++) {
                for (int y = 0; y < maxY; y++) {
                    if (this.get(x, y) != other.get(x, y)) {
                        return false;
                    }
                }
            }
            return true;
        }
        return false;
    }

    public final void print() {
        for (int r = 0; r < maxY; r++) {
            for (int c = 0; c < maxY; c++) {
                System.out.print(data[c + r * maxY] + ", ");
            }
            System.out.println();
        }
    }
}
